<%@ page language="java" contentType="text/html; charset=GBK"%>
<% 
  response.setHeader("Pragma","No-cache"); 
  response.setHeader("Cache-Control","no-cache"); 
  response.setDateHeader("Expires", 0); 
%>
<%@ page import="java.util.*"%>
<%@ page import="com.ionglobal.db.*" %>
<%@ page import="com.ionglobal.misc.*" %>
<%@ page import="com.ionglobal.lib.*" %>
<%@ page import="com.gzgi.weqs.partsmanage.PartsDifferentApp" %>
<%@ page import="com.gzgi.weqs.partsmanage.PartsDifferent" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ include file="/include/init_include.jsp" %>
<%
	int pageid = Request.getParameterInt("page",1);
	int pagesize = Request.getParameterInt("rows",20);
	int minpage = (pageid-1)+1;
	int maxpage = pageid*pagesize;
	String countSql = "select count(*) from pqm_partsdifferent";
	String sql = "select * from (select p.*,rownumber() over(order by iid asc) as rn from pqm_partsdifferent as p where dcurCriterionDate is null) as temp where temp.rn between "+minpage+" and "+maxpage;
	PartsDifferentApp partsDifferentApp = new PartsDifferentApp();
	int pagecount = partsDifferentApp.getPartsDifferentNum(dbi,countSql);
	List result = partsDifferentApp.getPartsDifferentList(dbi,sql,pageid,pagesize);
	
	StringBuffer stringBuffer = new StringBuffer();
	if(result!=null){
		stringBuffer.append("{");
		stringBuffer.append("\"total\":"+pagecount+",");
		stringBuffer.append("\"totalPage\":"+(pagecount/pagesize)+",");
		stringBuffer.append("\"rows\":");
		stringBuffer.append("[");
		for(Iterator it=result.iterator();it.hasNext();){
			PartsDifferent partsDifferent=(PartsDifferent)it.next();
			stringBuffer.append("{");
			stringBuffer.append("\"id\":"+partsDifferent.getId()+","); 
			stringBuffer.append("\"carType\":\""+partsDifferent.getCarType()+"\",");
			stringBuffer.append("\"level\":"+partsDifferent.getLevel()+",");
			stringBuffer.append("\"rowNumber\":"+partsDifferent.getPreRowNumber()+",");
			stringBuffer.append("\"partNo\":\""+partsDifferent.getPrePartsNo()+"\",");
			stringBuffer.append("\"partName\":\""+partsDifferent.getPartsName()+"\"");
			if(it.hasNext()){
               	stringBuffer.append("},");
            }
            else{
              	stringBuffer.append("}");
            }
		}
		stringBuffer.append("]");
		stringBuffer.append("}");
	}
	String info=stringBuffer.toString();
	out.println(info);
%>
<%@ include file="/include/init_free.jsp" %>
